<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<head>
		<link rel="stylesheet" href="${pageContext.request.contextPath}/jslib/jq_datatables/css/jquery.dataTables.css"	type="text/css" />
		<script type="text/javascript" language="javascript" src="${pageContext.request.contextPath}/jslib/jquery/jquery.js"></script>
		<script type="text/javascript" language="javascript" src="${pageContext.request.contextPath}/jslib/jq_datatables/js/jquery.dataTables.js"></script>
		<script src="${pageContext.request.contextPath}/jslib/jquery/jquery.json.min.js" type="text/javascript"></script>
		<style type="text/css">
body {
	margin: 2px;
}
		</style>
		<script type="text/javascript">
var urlGetData = '${pageContext.request.contextPath}/plugins/$${Obj.PluginName}$$/$${Obj.ClassNameAllLower}$$/findPage.ilf';
var iDisplayLength = 20;
var aoColumns = [ 
 ##{FIELD
 	{
	"mDataProp" : "$${ObjField.JsFieldNameFirstLower}$$"
	},
	}##];

var aoColumnDefs = [];

/*内部变量-表格变量*/
var oTable;
/*内部变量-条件列表*/
var conditions = [];

/*工具方法*/
function request(paras) {
	var url = location.href;
	var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
	var paraObj = {}
	for (i = 0; j = paraString[i]; i++) {
		paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j
				.indexOf("=") + 1, j.length);
	}
	var returnValue = paraObj[paras.toLowerCase()];
	if (typeof (returnValue) == "undefined") {
		return "";
	} else {
		return returnValue;
	}
}

/*表格刷新*/
function getData(sSource, aoData, fnCallback) {
	conditions = [ 
	/*处理接收参数拼接查询条件的KeyValue
	{
		"name" : "tablename",
		"value" : request('tableName")
	}, {
		"name" : "tableid",
		"value" : request('tableid")
	}*/ ];
	
	$.ajax( {
		type : "POST",
		url : sSource,
		dataType : "json",
		data : "tableparam=" + JSON.stringify(aoData) + "&conditions="
				+ JSON.stringify(conditions),
		success : function(data) {
			fnCallback(data); //服务器端返回的对象的returnObject部分是要求的格式 
	}
	});
};

/* 获取选择行对象 */
function getSelected(oTable) {
	var aReturn = new Array();
	var aTrs = oTable.fnGetNodes();
	for ( var i = 0; i < aTrs.length; i++) {
		if ($(aTrs[i]).hasClass('row_selected')) {
			aReturn.push(aTrs[i]);
			break;
		}
	}
	if (aReturn && aReturn.length == 1)
		return oTable.fnGetData(aReturn[0]);
	else
		return null;
}

/*初始化*/
$(document).ready(function() {
	var ph = 280;
	/*表格配置*/
	oTable = $('#example').dataTable( {
		"bSortClasses" : false,
		"aLengthMenu" : [ 15, 25, 50 ],//每页显示条数设置列表
		"bAutoWidth" : true, //不自动计算列宽度
		"bSort" : true,//是否允许排序
		"bProcessing" : true, //加载数据时显示正在加载信息		
		"bServerSide" : true, //指定从服务器端获取数据
		"bFilter" : false, //不使用过滤功能
		"bLengthChange" : true, //用户不可改变每页显示数量
		"sPaginationType" : "full_numbers", //翻页界面类型
		"bStateSave" : false, //保存状态到cookie,开启可保留搜索文本
		"bScrollCollapse" : true,//是否开启滚动条
		"sScrollY" : ph,//纵向滚动条
		"sScrollX" : "100%",//横向滚动条
		"aoColumns" : aoColumns,
		"aoColumnDefs" : aoColumnDefs,
		"iDisplayLength" : iDisplayLength, //默认每页显示的记录数
		"sDom" : '<"top">frt<"bottom"ilp><"clear">',
		"aaSorting" : [ [ 0, "asc" ] ],
		"fnServerData" : getData, //获取数据的处理函数
		"sAjaxSource" : urlGetData
	});

	/*事件处理*/
	$("#example tbody").click(function(event) {
		$(oTable.fnSettings().aoData).each(function() {
			$(this.nTr).removeClass('row_selected');
		});
		if ($(event.target.parentNode).attr('class') == 'even'|| $(event.target.parentNode).attr('class') == 'odd') {
			$(event.target.parentNode).addClass('row_selected');
		}
	});	
});
</script>
	</head>
	<body>
		<!-- 查询条件-->
		<div class="table_conditions">
			<div style="float: right;">
			</div>
			显示名称
		</div>
		<!-- 表格呈现 -->
		<table cellpadding="0" cellspacing="0" border="0" id="example">
			<thead>
				<tr>
					##{FIELD					
					<th>$${ObjField.JsFieldNameFirstLower}$$</th>
					}##
				</tr>
			</thead>
			<tbody>
			</tbody>
		</table>
	</body>
</html>